// -*-mode:c++; coding:utf-8-*-

#ifndef _XBASE_ERROR_THROW_ERROR_HPP_
#define _XBASE_ERROR_THROW_ERROR_HPP_

#include <boost/system/error_code.hpp>
#include <boost/system/system_error.hpp>
#include <boost/throw_exception.hpp>

namespace xbase
{
	namespace error
	{
		void throw_error(const boost::system::error_code &ec)
		{
			if(ec)
			{
				boost::system::system_error e(ec);
#ifndef BOOST_THROW_EXCEPTION
				boost::throw_exception(e);
#else
				BOOST_THROW_EXCEPTION(e);
#endif	// BOOST_THROW_EXCEPTION
			}
		}
	} // namespace error

} // namespace xbase

#endif	// _XBASE_ERROR_THROW_ERROR_HPP_
